package com.ljkj.cordial.chat.presenter;

import android.util.SparseArray;

/**
 * chat
 */
public class ChatPresenterFactory {

    private static SparseArray<AChatPresenter> array = new SparseArray<>();

    public static AChatPresenter create(int type, int direction) {
        if (AChatPresenter.EMOJI == type) {
            array.put(type, new PicturePresenter(direction));
            return array.get(type);
        } else if (AChatPresenter.FILE == type) {
            array.put(type, new FilePresenter(direction));
            return array.get(type);
        } else if (AChatPresenter.TEXT == type) {
            array.put(type, new TextPresenter(direction));
            return array.get(type);
        } else if (AChatPresenter.PICTURE == type) {
            array.put(type, new PicturePresenter(direction));
            return array.get(type);
        } else if (AChatPresenter.VOICE == type) {
            array.put(type, new VoicePresenter(direction));
            return array.get(type);
        } else if (AChatPresenter.VIDEO == type) {
            array.put(type, new VideoPresenter(direction));
            return array.get(type);
        } else if (AChatPresenter.READ_FINISH == type) {
            array.put(type, new ReadFinishTextPresenter(direction));
            return array.get(type);
        }
        array.put(type, new HistoryTimePresenter(direction));
        return array.get(type);
    }

    public static AChatPresenter get(int type) {
        return array.get(type);
    }

    public static void clear() {
        array.clear();
    }
}
